

<!--
 * @Description: 乳腺屏片
 * 
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved. 
-->
<template>
  <div class="content">
      <div id="table1">
				<div class="innertitle">
					1.标准照片密度: <el-checkbox v-model="form1.notHave">设备无自动曝光控制功能</el-checkbox>
				</div>

				<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
					<tr>
						<td rowspan="2">模体厚度,cm</td>
						<td colspan="5">自动曝光条件</td>
						<td colspan="2">光密度,D</td>
					</tr>
          <tr>
            <td>靶/滤过</td>
            <td>控制模式</td>
            <td>密度补偿</td>
            <td>kV</td>
            <td>mAs</td>
            <td>测量值</td>
            <td>基线值</td>
          </tr>
          <tr>
            <td>4</td>
            <td style="display: flex;">
              <el-select
								v-model="form1.target"
								placeholder="请选择靶"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.target_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
              <el-select
								v-model="form1.filtration"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.filtration_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
            </td>
            <td>
              <el-select
								v-model="form1.controlModel"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="item in controlModelList"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
							</el-select>
            </td>
            <td><el-input v-model="form1.densityCompensation"/></td>
            <td><el-input v-model="form1.tubeVoltage"/></td>
            <td><el-input v-model="form1.tubeCurrent"/></td>
            <td><el-input v-model="form1.readoutValue"/></td>
            <td><el-input v-model="form1.baselineValue"/></td>
          </tr>
				</table>
			</div>
      
      <div id="table2">
				<div class="innertitle">
					2.AEC响应: <el-checkbox v-model="form2.notHave">设备无自动曝光控制功能</el-checkbox>
				</div>

				<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
					<tr>
						<td rowspan="2">模体厚度,cm</td>
						<td colspan="5">自动曝光条件</td>
						<td colspan="2">光密度,OD</td>
					</tr>
          <tr>
            <td>靶/滤过</td>
            <td>控制模式</td>
            <td>密度补偿</td>
            <td>kV</td>
            <td>mAs</td>
            <td>测量值</td>
            <td>与4cm 值比较</td>
          </tr>
          <tr>
            <td>2</td>
            <td rowspan="3">
              <el-select
								v-model="form2.target"
								placeholder="请选择靶"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.target_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
              <el-select
								v-model="form2.filtration"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.filtration_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>  
            </td>
            <td rowspan="3">
              <el-select
								v-model="form2.controlModel"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="item in controlModelList"
                  :key="item.id"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
							</el-select>
            </td>
            <td rowspan="3"><el-input v-model="form2.densityCompensation"/></td>
            <td><el-input v-model="form2.tubeVoltage_2"/></td>
            <td><el-input v-model="form2.tubeCurrent_2"/></td>
            <td><el-input v-model="form2.readoutValue_2"/></td>
            <td><el-input v-model="form2.compare_2"/></td>
          </tr>
          <tr>
            <td>4</td>
            <td><el-input v-model="form2.tubeVoltage_4"/></td>
            <td><el-input v-model="form2.tubeCurrent_4"/></td>
            <td><el-input v-model="form2.readoutValue_4"/></td>
            <td>——</td>
          </tr>
          <tr>
            <td>6</td>
            <td><el-input v-model="form2.tubeVoltage_6"/></td>
            <td><el-input v-model="form2.tubeCurrent_6"/></td>
            <td><el-input v-model="form2.readoutValue_6"/></td>
            <td><el-input v-model="form2.compare_6"/></td>
          </tr>
				</table>
			</div>

      <div id="table3">
				<div class="innertitle">
					3.高对比度分辨力
				</div>

				<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
					<tr>
						<td>方向</td>
						<td>焦点</td>
						<td>靶/滤过</td>
						<td>kV</td>
						<td>mAs</td>
						<td>高对比度分辨力,lp/mm</td>
					</tr>
          <tr>
            <td>水平</td>
            <td><el-input v-model="form3.focusLevel"/></td>
            <td>
                <el-select
								v-model="form3.targetLevel"
								placeholder="请选择靶"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.target_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
              <el-select
								v-model="form3.filtrationLevel"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.filtration_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
            </td>
            <td><el-input v-model="form3.tubeVoltageLevel"/></td>
            <td><el-input v-model="form3.tubeCurrentLevel"/></td>
            <td><el-input v-model="form3.contrastResolutionHighLevel"/></td>
          </tr>
          <tr>
            <td>垂直</td>
            <td><el-input v-model="form3.focusVertical"/></td>
            <td>
                <el-select
								v-model="form3.targetVertical"
								placeholder="请选择靶"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.target_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
              <el-select
								v-model="form3.filtrationVertical"
								placeholder="请选择滤过"
                style="width: 120px; display: inline-block"
                class="inputborder"
								clearable>
                <el-option
                  v-for="dict in dict.type.filtration_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
							</el-select>
            </td>
            <td><el-input v-model="form3.tubeVoltageVertical"/></td>
            <td><el-input v-model="form3.tubeCurrentVertical"/></td>
            <td><el-input v-model="form3.contrastResolutionHighVertical"/></td>
          </tr>
				</table>
			</div>
  </div>
</template>

<script>
import {getInfoById10, density, aec, high} from '@/api/testItem/item10'

export default {
  name: "testItem10",
  dicts: ["target_type", "filtration_type"],
  data() {
    return {
      // tab切换通用数据
			form: {},
			// 表单-1.标准照片密度
			form1: {

			},
			// 表单-2.AEC响应
			form2: {

			},
      // 3.高对比度分辨力
      form3: {

      },
			itemsId: null,
      controlModelList: [
        {
          id: 1,
          label: '普通模式',
          value: 1
        },
        {
          id: 2,
          label: 'DBT',
          value: 2
        },
      ], // 控制模式
    };
  },
  props: {
		// tab栏
    activeNameEquipment: {
			type: String,
      default: "0",
    },
		// 基本信息数据
    basicForm: {
			type: Object,
      default: () => {
				return {}
			},
    },
  },
  watch: {
    activeNameEquipment: {
      handler(val) {
        let _this = this
				this.$nextTick(()=>{
          // 获取详情
          getInfoById10(this.basicForm.resultId).then(response => {
            let {density, aec, contrastResolutionHigh, itemsId, resultId} = response.data
            this.itemsId =  response.data?.itemsId;
            // 1.标准照片密度
            this.form1 =  density || {};
            // 2.AEC响应
            this.form2 =  aec || {};
            // 3.高对比分辨力
            this.form3 =  contrastResolutionHigh || {};
          }).catch((response) => {
            console.log("catch-->getInfoById06", response);
            this.$emit("loadingchange", true);
          });
          // 绑定请求
          let itemsLength = 3;
          for (let index = 0; index < itemsLength; index++) {
            
            let tableInputs = document.getElementById(`table${index + 1}`).getElementsByTagName("input");
            for (let i = 0; i < tableInputs.length; i++) {
							this.bind(tableInputs[i], () => {
								this.submitTestForm(index + 1)
							})
              // let elSelect = this.elHaveComponent(tableInputs[i]) // 获取Component
              // elSelect.$on('change', function(){
              //   _this.validate(tableInputs[i])
              //   _this.submitTestForm(index + 1)
              // })
            }
            
          }
				})
      },
      deep: true,
      immediate: true
    },
  },
  methods: {
    // 直接荧光屏透视设备专用检测项目-02
		submitTestForm(index) {
			this.$emit("loadingchange", true); /* 说明绑定成功 */
			this[`form${index}`].itemsId = this.itemsId;
			switch (index) {
				// 1.DAS动态范围。DAS对比灵敏度 伪影
				case 1:
          density(this.form1).then((response) => {
						// this.$modal.msgSuccess("保存成功");
						response.data ? this.form1 = response.data : "";
						this.$emit("loadingchange", false);
					})
        	break;
        case 2:
          aec(this.form2).then((response) => {
						// this.$modal.msgSuccess("保存成功");
						response.data ? this.form2 = response.data : "";
						this.$emit("loadingchange", false);
					})
        	break;
        case 3:
          high(this.form3).then((response) => {
						// this.$modal.msgSuccess("保存成功");
						response.data ? this.form3 = response.data : "";
						this.$emit("loadingchange", false);
					})
        	break;
			}
		},
  },
};
</script>

<style lang="scss" scoped>
@import '../content.scss';
</style>